﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xTeam.HengLe.Enums;
using System.ComponentModel;

namespace xTeam.Hengle.Helper
{
    public static class CustomerControl
    {
        /// <summary>
        /// 订单状态下拉框
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string OrderStateSelect(int selValue, [DefaultValue("state")]string id, [DefaultValue("state")]string name)
        {
            StringBuilder str = new StringBuilder();
            str.AppendLine(string.Format("<select id='{0}' name='{1}'>", id, name));
            str.AppendLine(string.Format("<option value='{0}' {2} >{1}</option>", (int)OrderState.UnPay, StringExtendFun.OrderStateForManage((int)OrderState.UnPay), SelectedValue(selValue,OrderState.UnPay)));
            str.AppendLine(string.Format("<option value='{0}' {2} >{1}</option>", (int)OrderState.WAIT_BUYER_PAY, StringExtendFun.OrderStateForManage((int)OrderState.WAIT_BUYER_PAY), SelectedValue(selValue, OrderState.WAIT_BUYER_PAY)));
            str.AppendLine(string.Format("<option value='{0}' {2} >{1}</option>", (int)OrderState.WAIT_SELLER_SEND_GOODS, StringExtendFun.OrderStateForManage((int)OrderState.WAIT_SELLER_SEND_GOODS), SelectedValue(selValue, OrderState.WAIT_SELLER_SEND_GOODS)));
            str.AppendLine(string.Format("<option value='{0}' {2} >{1}</option>", (int)OrderState.WAIT_BUYER_CONFIRM_GOODS, StringExtendFun.OrderStateForManage((int)OrderState.WAIT_BUYER_CONFIRM_GOODS), SelectedValue(selValue, OrderState.WAIT_BUYER_CONFIRM_GOODS)));
            str.AppendLine(string.Format("<option value='{0}' {2} >{1}</option>", (int)OrderState.TRADE_FINISHED, StringExtendFun.OrderStateForManage((int)OrderState.TRADE_FINISHED), SelectedValue(selValue, OrderState.TRADE_FINISHED)));
            str.AppendLine("</select>");
            return str.ToString();
        }

        private static string SelectedValue(int selValue,OrderState state)
        {
            return selValue == (int)state ? "selected=\"selected\"" : "";
        }
    }
}
